package com.example.hotel_lxy.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.example.hotel_lxy.R;
import com.ysxsoft.common_base.utils.DisplayUtils;


/**
* 预定
* create by Sincerly on 9999/9/9 0009
**/
public class SendReserveDialog extends Dialog {
    private Context mContext;

    private static String texts;
    public SendReserveDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        this.mContext = context;

//        init();
    }

    private View init() {
        View view = View.inflate(mContext, R.layout.dialogsendreserve, null);
        TextView text=view.findViewById(R.id.text);
        text.setText(""+texts);
        TextView text_qd=view.findViewById(R.id.text_qd);
        text_qd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                listener.onPositiveClick("1");
                dismiss();
            }
        });
        TextView text_qx=view.findViewById(R.id.text_qx);
        text_qx.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        return view;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setCanceledOnTouchOutside(true);
        setContentView(init());
    }

    public void showDialog() {
        if (!isShowing()) {
            show();
            WindowManager.LayoutParams lp = getWindow().getAttributes();
//            lp.height = DisplayUtils.getDisplayWidth(mContext) * 5 / 5;
            lp.width = DisplayUtils.getDisplayWidth(mContext) * 6 / 10;
            lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
//            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            getWindow().setAttributes(lp);
            getWindow().setGravity(Gravity.CENTER);
        }
    }

    public static SendReserveDialog show(Context context, OnDialogClickListener listener, String text) {
        SendReserveDialog dialog = new SendReserveDialog(context, R.style.BottomDialogStyle);
        dialog.setListener(listener);
        texts=text;
        dialog.showDialog();
        return dialog;
    }


    private OnDialogClickListener listener;
    public SendReserveDialog setListener(OnDialogClickListener listener) {
        this.listener = listener;
        return this;
    }

    public interface OnDialogClickListener {
        /**
         * 点击确定按钮事件
         */
        public void onPositiveClick(String s);
    }
}